package com.zbkj.dal.pojo.vo;

import com.zbkj.dal.entity.product.ProductBrand;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Data
@ApiModel
public class BrandListVO {

    @ApiModelProperty(value = "品牌编号", example = "1")
    private Integer brandId;

    @ApiModelProperty(value = "品牌名称", example = "LV")
    private String brandName;

    @ApiModelProperty(value = "图标", example = "")
    private String icon;

    public static List<BrandListVO> generate(List<ProductBrand> brands) {
        if (CollectionUtils.isEmpty(brands)) {
            return new ArrayList<>();
        }
        return brands.stream().map(brand -> {
            BrandListVO brandListVO = new BrandListVO();
            brandListVO.setBrandId(brand.getId());
            brandListVO.setBrandName(brand.getName());
            brandListVO.setIcon(brand.getIcon());
            return brandListVO;
        }).collect(Collectors.toList());
    }

}
